package com.cyt.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cyt.dao.impl.GongShiDaoImpl;
import com.cyt.dao.impl.SPFeiLeiDaoImpl;
import com.cyt.dao.impl.ShangPingXXDaoImpl;
import com.cyt.dao.impl.XingWenAnLiDaoImpl;
import com.cyt.dao.impl.XingWengXiZhiDaoImpl;
import com.cyt.entity.GongShi;
import com.cyt.entity.SPFeiLei;
import com.cyt.entity.ShangPingXX;
import com.cyt.entity.XingWengXiZhi;


//首页servlet 
public class HomeServlet extends HttpServlet {
	// 该方法获取设计师的信息
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 //调用实现类
		//调用dao层方法获得数据和响应数据
		
		//公司的
		GongShiDaoImpl cDao= new GongShiDaoImpl();//创建对象
	    GongShi g=cDao.getGongShi();//调用方法获得用户集合
	    request.setAttribute("g", g);
		
	    
	    //商品分类  传图片
		SPFeiLeiDaoImpl sDao= new SPFeiLeiDaoImpl();//创建对象
	    List <SPFeiLei> list=sDao.getSPFeiLei();//调用方法获得用户集合
	   request.setAttribute("sp", list);//将数据存入request中
	   
	   //商品案例
	   ShangPingXXDaoImpl spDao=new ShangPingXXDaoImpl();
	   List <ShangPingXX> sPList =  spDao.getShangPingAnLi();
	   request.setAttribute("shangAnLi", sPList);//将数据存入request中
	   //新闻案例
	   XingWenAnLiDaoImpl xWXZDao=new XingWenAnLiDaoImpl();
	   List <XingWengXiZhi> xWList =  xWXZDao.getXingWengAnLi();
	   request.setAttribute("XingWenAnLiList", xWList);//将数据存入request中
	   request.getRequestDispatcher("index.jsp").forward(request, response);

	   
	   
	}
   
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
